package com.fidku 
{
	import com.meetup.MeetupMobile;
	import com.meetup.methods.Members;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.MouseEvent;
	import flash.geom.Rectangle;
	import flash.media.StageWebView;
	
	/**
	 * Meetup Adobe AIR Example
	 * @author Patricio Cornejo
	 * @link http://www.as3resources.com
	 */
	public class Example extends Sprite 
	{
		private const clienId:String = "";
		private const secretKey:String = "";
		private const redirectUri:String = "http://fidku.com";
		
		private var swv:StageWebView;
		
		public function Example():void
		{
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.EXACT_FIT;
			button.addEventListener(MouseEvent.CLICK, clickButton);
		}
		
		private function clickButton(e:MouseEvent):void
		{
			MeetupMobile.authorize(authReady, getSWV(), clienId, secretKey, redirectUri);
		}
		
		private function authReady(response:Object):void 
		{
			if (response.success) {
				//Members.byId(mReady, "self", null);
				Members.byGroup(gReady, [176399]);
			} else {
				trace("ERROR");
				trace(response.errorCode, response.errorMessage);
			}
		}
		
		private function gReady(response:Object):void 
		{
			trace(JSON.stringify(response));	
		}
		
		private function mReady(response:Object):void 
		{
			trace(JSON.stringify(response));
		}
		
		private function getSWV():StageWebView
		{
			if (!swv) {
				swv = new StageWebView();
				swv.stage = this.stage;
				swv.viewPort = new Rectangle(0, 0, stage.fullScreenWidth, stage.fullScreenHeight);
			}
			
			return swv;
		}
	}

}